package feign.okhttp.learn.controller;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import feign.okhttp.learn.feign.Feign404Service;
import feign.okhttp.learn.feign.FeignTimeOutService;
import feign.okhttp.learn.feign.HelloFeignService;
import feign.okhttp.learn.feign.ProjectConflictCheckClient;


@RestController
public class HelloFeignController {

    @Autowired
    private HelloFeignService helloFeignService;

    @Resource
    private Feign404Service feign404Service;

    @Resource
    private FeignTimeOutService feignTimeOutService;

    @Resource
    private ProjectConflictCheckClient projectConflictCheckClient;
    @GetMapping(value = "/search/github")
    public String searchGithubRepoByStr(@RequestParam("str") String queryStr) {
        return helloFeignService.searchRepo(queryStr);

    }

    @GetMapping(value = "/search/404")
    public String searchGithubRepoByStr404(@RequestParam("str") String queryStr) {
        return feign404Service.searchRepo(queryStr);
    }

    @GetMapping(value = "/search/timeout")
    public String searchGithubRepoByStrTimeout(@RequestParam("str") String queryStr) {
        return feignTimeOutService.searchRepo(queryStr);
    }


    @GetMapping(value = "/biz/project/check")
    public void checkProject() {
        String s = projectConflictCheckClient.doCheck("lyctjcAction", "test1", "test1");
        System.out.println(s);
    }
}
